package com.financial.transactionhistory.service.impl;

import java.math.BigDecimal;
import java.util.List;
import java.util.Arrays;
        import com.financial.common.utils.DateUtils;
import com.financial.common.utils.SecurityUtils;
import com.financial.transactionhistory.domain.FinancialTransaction;
import com.financial.transactionhistory.vo.FinancialDashboardVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.financial.transactionhistory.mapper.FinancialDashboardMapper;
import com.financial.transactionhistory.domain.FinancialDashboard;
import com.financial.transactionhistory.service.IFinancialDashboardService;

import com.financial.transactionhistory.mapper.FinancialDashboardMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Arrays;

/**
 * 财务概览Service业务层处理
 *
 * @author ruoyi
 * @date 2025-06-16
 */
@Service
public class FinancialDashboardServiceImpl extends ServiceImpl<FinancialDashboardMapper, FinancialDashboard> implements IFinancialDashboardService
{
    @Autowired
    private FinancialDashboardMapper financialDashboardMapper;


    /**
     * 查询财务概览列表
     *
     * @param
     * @return 财务概览
     */
    @Override
    public FinancialDashboardVo selectDashboard() {
        //查询当前用户的所有支出
        Long userId = SecurityUtils.getUserId();
        BigDecimal expenses = financialDashboardMapper.findExpenses(userId);
        //查询当前用户的收入
        BigDecimal income = financialDashboardMapper.findIncome(userId);

        //查询当前用户各项预算
        List<FinancialDashboard>  financialDashboardList = financialDashboardMapper.findUserAllDashboard(userId);
        //封装数据
        FinancialDashboardVo financialDashboardVo = new FinancialDashboardVo();
        financialDashboardVo.setExpenses(expenses);
        financialDashboardVo.setIncome(income);
        financialDashboardVo.setBudgets(financialDashboardList);
        return financialDashboardVo;


    }

}